﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Runtime;
using System.Data;
using System.IO.Ports;
using System.Resources;
using System.Diagnostics;
/*Created by Taranoshi c2013
 * Licensed under the GNU GPL (General Public License)
 * This software is free to use and distribute and/or modify.
 * */

/*==================Change List========================================
 * C-DOS Version 1.0: First version of C-DOS(run command does not work)
 * =====
 * C-DOS Version 1.0.1: minor bug fixes
 * =====
 * C-DOS Version 1.1.0: added the math program/command,
 * tweeked the user interface/boot screen, fixed the run command
 * =====
 * C-DOS Version 1.1.2: added more information to the ver command,
 * modified the boot sequence, made a few minor tweeks
 * =====
 * C-DOS Version 1.2.0:added new commands: chkdsk, defrag, 
 * systemconsole, tree, wexplore, calc, and music.
 * =====
 * C-DOS Version 1.2.1: Reversion of version 1.2.0,
 * changed boot(slightly), added Username feature, 
 * updated the "ver" command, added 3 new commands(movdir, mdir, and ddir). 
 * For Coders: added the change list, and simplified some of the code.
 * =====
 * C-DOS Version 1.2.3: Added 2 new commands, "ls, and login. Also added a "logging" feature.
 * =====
 * C-DOS Version 1.2.4: fixed a bug with the "ls" command, added new BootManager
 * =====
 * C-DOS Version 1.2.4b: Shortened boot process and the user command manager
 * */
namespace C_DOS
{
    class Program
    {
        private static object c;
        void COMMANDERROR()
        {
            Console.WriteLine("ERROR: No such command found!!!");
        }
        static void Main(string[] args)
        {
        boot://begin "boot" sequence:
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.Title = "Booting C-DOS.....";
            string welcome = "Welcome to C-DOS";
            string bootstart = "Begining the boot process...";
            string bootload = "BootLoader executing.....";
            string loadmainsys = "Loading Main System files.....";
            Console.WriteLine("Welcome to C-DOS!");
            Console.WriteLine("Booting.....");
            Console.WriteLine("====================================================================================================");
            Console.WriteLine("|                                                                                        ");
            Console.WriteLine("====================================================================================================");
            Console.Clear();
            Console.WriteLine("Welcome to C-DOS!");
            Console.WriteLine("Booting.....");
            Console.WriteLine("====================================================================================================");
            Console.WriteLine("||                                                                                         ");
            Console.WriteLine("====================================================================================================");
            Console.Clear();
            Console.WriteLine("Welcome to C-DOS!");
            Console.WriteLine("Booting.....");
            Console.WriteLine("====================================================================================================");
            Console.WriteLine("|||                                                                                   ");
            Console.WriteLine("====================================================================================================");
            Console.Clear();
            Console.WriteLine("Welcome to C-DOS!");
            Console.WriteLine("Booting.....");
            Console.WriteLine("====================================================================================================");
            Console.WriteLine("||||                                                                                 ");
            Console.WriteLine("====================================================================================================");
            Console.Clear();
            Console.WriteLine("Welcome to C-DOS!");
            Console.WriteLine("Booting.....");
            Console.WriteLine("====================================================================================================");
            Console.WriteLine("|||||                                                                                ");
            Console.WriteLine("====================================================================================================");
            Console.Clear();
            Console.WriteLine("Welcome to C-DOS!");
            Console.WriteLine("Booting.....");
            Console.WriteLine("====================================================================================================");
            Console.WriteLine("||||||                                                                                  ");
            Console.WriteLine("====================================================================================================");
            Console.Clear();
            Console.WriteLine("Welcome to C-DOS!");
            Console.WriteLine("Booting.....");
            Console.WriteLine("====================================================================================================");
            Console.WriteLine("|||||||                                                                                 ");
            Console.WriteLine("====================================================================================================");
            Console.Clear();
            Console.WriteLine("Welcome to C-DOS!");
            Console.WriteLine("Booting.....");
            Console.WriteLine("====================================================================================================");
            Console.WriteLine("||||||||                                                                               ");
            Console.WriteLine("====================================================================================================");
            Console.Clear();
            Console.WriteLine("Welcome to C-DOS!");
            Console.WriteLine("Booting.....");
            Console.WriteLine("====================================================================================================");
            Console.WriteLine("|||||||||                                                                               ");
            Console.WriteLine("====================================================================================================");
            Console.Clear();
            Console.WriteLine("Welcome to C-DOS!");
            Console.WriteLine("Booting.....");
            Console.WriteLine("====================================================================================================");
            Console.WriteLine("||||||||||                                                                             ");
            Console.WriteLine("====================================================================================================");
            Console.Clear();
            string HELP = "help";//create some of the commands
            string DIRECTORY = "dir";
            string EDIT = "edit";
            string VER = "ver";
            string RESTART = "restart";
            string SHUTOFF = "shutdown";
            string CLEAR = "clr";
            string RUN = "run";
            string MATH = "math";
            string LIST = "ls";
            string BCK = "back";
            string EXT = "exit";
            string chkdsk = "chkdsk";
            string def = "defrag";
            string cmd = "systemconsole";
            string GETCURRENT = Directory.GetCurrentDirectory();
            string BCKGROUND = "BackgroundColor == 'black'";
            string FORGROUND = "ForgroundColor == 'white'";
            string WINHEIGHT = "WindowHeight == '30'";
            string WINWIDTH = "WindowWidth == '80'";
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.Black;
        Cont:
            if (File.Exists(GETCURRENT + "\\log.txt"))
            {
                StreamWriter SETUPFILE = new StreamWriter(File.OpenWrite(GETCURRENT + "\\log.txt"));
                SETUPFILE.WriteLine("===============C-DOS Log File===============");
                SETUPFILE.WriteLine(BCKGROUND);
                SETUPFILE.WriteLine(FORGROUND);
                SETUPFILE.WriteLine(WINHEIGHT);
                SETUPFILE.WriteLine(WINWIDTH);
                SETUPFILE.WriteLine(DateTime.Today.ToString() + "Booting......");
                //finished with the "boot" process, head to login
                Console.WriteLine("Done with the booting process.");
                Console.Clear();
                Console.Title = "C-DOS Login:";
                Console.WriteLine("User logging in.....");
            Login://if you want to re-loggin
                Console.Write("Please enter a Username:");
                string username = Console.ReadLine();
                SETUPFILE.WriteLine(DateTime.Today.ToString() + "Logged in with username:" + username);
                Console.Clear();
                Console.Title = "C-DOS";
                Console.WriteLine("Welcome " + username + " to C-DOS! :-)");//hello user
                Console.WriteLine("Note: this software must be run with administrator privilages,");
                Console.WriteLine("or some features(like the chkdsk command and the defrag command) will not work.");
            begin://main loop start

                string DateAndTime = DateTime.Today.Date.ToShortDateString();
                Console.WriteLine(DateAndTime);
                Console.Write("\\" + username + "@CDOS:");
                string command = Console.ReadLine();
                SETUPFILE.WriteLine(DateTime.Today.ToString() + "Command Entered:" + command);
                try
                {
                    if (command == HELP)//help menu command
                    {
                        Console.WriteLine("=================CDOS_Help==================");
                        Console.WriteLine("| help     = help menu(obviously)          |");
                        Console.WriteLine("| dir      = current working directory     |");
                        Console.WriteLine("| edit     = C-DOS TextWriter              |");
                        Console.WriteLine("| math     = Math program(calculator)      |");
                        Console.WriteLine("| ver      = C-DOS Version                 |");
                        Console.WriteLine("| restart  = restart C-DOS                 |");
                        Console.WriteLine("| shutdown = shutdown C-DOS                |");
                        Console.WriteLine("| exit     = shutdown C-DOS                |");
                        Console.WriteLine("| clr      = clear the screen              |");
                        Console.WriteLine("| mdir     = make a directory              |");
                        Console.WriteLine("| movdir   = move a directory              |");
                        Console.WriteLine("| ddir     = delete a directory            |");
                        Console.WriteLine("| login    = re-login with a different name|");
                        Console.WriteLine("| run      = run an external program       |");
                        Console.WriteLine("| NOTE: must be located in current         |");
                        Console.WriteLine("| working directory                        |");
                        Console.WriteLine("=============External Commands==============");
                        Console.WriteLine("| chkdsk   = start the Check Disk Program  |");
                        Console.WriteLine("| defrag   = start the Defrag Program      |");
                        Console.WriteLine("| systemconsole = goto the Windows CMD     |");
                        Console.WriteLine("| tree     = reads the drive               |");
                        Console.WriteLine("| wexplore = start Windows File Explorer   |");
                        Console.WriteLine("| calc     = start the Windows Calc.exe    |");
                        Console.WriteLine("| music    = start Windows Media Player    |");
                        Console.WriteLine("============================================");
                        goto begin;
                    }
                    else
                        if (command == LIST)
                        {
                            Console.WriteLine("=================CDOS_Help==================");
                            Console.WriteLine("| help     = help menu(obviously)          |");
                            Console.WriteLine("| dir      = current working directory     |");
                            Console.WriteLine("| edit     = C-DOS TextWriter              |");
                            Console.WriteLine("| math     = Math program(calculator)      |");
                            Console.WriteLine("| ver      = C-DOS Version                 |");
                            Console.WriteLine("| restart  = restart C-DOS                 |");
                            Console.WriteLine("| shutdown = shutdown C-DOS                |");
                            Console.WriteLine("| exit     = shutdown C-DOS                |");
                            Console.WriteLine("| clr      = clear the screen              |");
                            Console.WriteLine("| mdir     = make a directory              |");
                            Console.WriteLine("| movdir   = move a directory              |");
                            Console.WriteLine("| ddir     = delete a directory            |");
                            Console.WriteLine("| login    = re-login with a different name|");
                            Console.WriteLine("| run      = run an external program       |");
                            Console.WriteLine("| NOTE: must be located in current         |");
                            Console.WriteLine("| working directory                        |");
                            Console.WriteLine("=============External Commands==============");
                            Console.WriteLine("| chkdsk   = start the Check Disk Program  |");
                            Console.WriteLine("| defrag   = start the Defrag Program      |");
                            Console.WriteLine("| systemconsole = goto the Windows CMD     |");
                            Console.WriteLine("| tree     = reads the drive               |");
                            Console.WriteLine("| wexplore = start Windows File Explorer   |");
                            Console.WriteLine("| calc     = start the Windows Calc.exe    |");
                            Console.WriteLine("| music    = start Windows Media Player    |");
                            Console.WriteLine("============================================");
                            goto begin;
                        }
                        else
                            if (command == DIRECTORY)//dir command
                            {
                                string dir = Directory.GetCurrentDirectory();
                                Console.WriteLine(dir);
                                goto begin;
                            }
                            else
                                if (command == EDIT)//edit command
                                {
                                    Console.WriteLine("Welcome to DOSWriter");
                                    Console.WriteLine("Version 1.0.0");
                                dosedit://doswriter main loop
                                    Console.Write("\\" + username + "\\DOSWriter@CDOS:");
                                    string editcom = Console.ReadLine();
                                    SETUPFILE.WriteLine(DateTime.Today.ToString() + "Command Entered into DOSWriter:" + editcom);
                                    if (editcom == "help")//doswriter help command
                                    {
                                        Console.WriteLine("==========DOSWriterHelp==========");
                                        Console.WriteLine("| help   = DOSWriter Help Menu  |");
                                        Console.WriteLine("| new    = new text file        |");
                                        Console.WriteLine("| open   = open a text file     |");
                                        Console.WriteLine("| exit   = exit the writer      |");
                                        Console.WriteLine("| clr    = Clear the screen     |");
                                        Console.WriteLine("|                               |");
                                        Console.WriteLine("| Note: Files written in this   |");
                                        Console.WriteLine("| writer will be saved in the   |");
                                        Console.WriteLine("| '.dat' format.                |");
                                        Console.WriteLine("=================================");
                                        goto dosedit;
                                    }
                                    else
                                        if (editcom == "new")//doswriter create a new file command
                                        {
                                            Console.Write(">");
                                            string docslotsource = Console.ReadLine();
                                            long docslot = Convert.ToInt32(docslotsource);
                                        beginsave://the save file "dialog" mini-loop
                                            Console.WriteLine("Do you wish to save this Document?");
                                            Console.Write("[y] or [n]");
                                            string savedialog = Console.ReadLine();
                                            if (savedialog == "y")//say yes to saving the document you just typed
                                            {
                                                Console.WriteLine("Note: Document will be saved in current working directory.");
                                                Console.Write("Name for Document:");//give it a name
                                                string documentname = Console.ReadLine();
                                                string documentsavedirectory = Directory.GetCurrentDirectory();
                                                BinaryWriter documentwriter = new BinaryWriter(File.Create(documentsavedirectory + documentname));//create the document with the name provided in the working directory
                                                documentwriter.Write(docslot);//write the contents typed
                                                goto dosedit;
                                            }
                                            else
                                                if (savedialog == "n")//say no to save, get rid of the hard work of typing
                                                {
                                                    Console.WriteLine("Ok, document not saved.");
                                                    SETUPFILE.WriteLine(DateTime.Today.ToString() + "Document successively saved");
                                                    goto dosedit;
                                                }
                                                else
                                                {
                                                    Console.WriteLine("ERROR: Not a correct answer.");//oh no, an error
                                                    SETUPFILE.WriteLine(DateTime.Today.ToString() + "C-DOS Writer error:" + savedialog + "not correct answer to question");
                                                    goto beginsave;
                                                }
                                        }
                                        else
                                            if (editcom == "open")//lets open a previously made file
                                            {
                                            OpenDocLoop:
                                                Console.Write("Enter the Directory:");//enter the directory of the file
                                                string docdirectory = Console.ReadLine();
                                                if (docdirectory == "exit")
                                                {
                                                    Console.WriteLine("Document not opened");
                                                    SETUPFILE.WriteLine(DateTime.Today.ToString() + "Document not opened because 'exit' was typed");
                                                    goto dosedit;
                                                }
                                                else
                                                    try
                                                    {
                                                        BinaryReader documentreader = new BinaryReader(File.Open(docdirectory, FileMode.Open));
                                                        string thedocument = documentreader.ReadString();//open the file and read the contents
                                                        Console.WriteLine(thedocument);
                                                        SETUPFILE.WriteLine(DateTime.Today.ToString() + "Document successively opened in DOSWriter");
                                                    }
                                                    catch
                                                    {
                                                        Console.WriteLine("ERROR: Directory not found!!!");
                                                        goto OpenDocLoop;
                                                    }
                                                goto dosedit;
                                            }
                                            else
                                                if (editcom == CLEAR)//clear the screen(for the doswriter loop)
                                                {
                                                    Console.Clear();
                                                    goto dosedit;
                                                }
                                                else
                                                    if (editcom == "exit")//exit the doswriter "program"
                                                    {
                                                        goto begin;
                                                    }
                                                    else
                                                        if (editcom == "")//if you like to type random stuff, this helps prohibit errors
                                                        {
                                                            goto dosedit;
                                                        }
                                }
                                else
                                    if (command == VER)//dos version command
                                    {
                                        SETUPFILE.WriteLine(DateTime.Today.ToString() + "Ver command executed");
                                        string datecreated = ("Detailed version:         1.2.4.6192013");//wow, a new version of C-DOS!!!
                                        string dosversion = ("C-DOS Version:            1.2.3");
                                        string kernelversion = ("C-DOS Kernel version:     2.1");
                                        string bootloaderver = ("C-DOS bootloader version 10.1");
                                        string doswriterver = ("DOS Writer version:       2.3");
                                        string helpver = ("Help menu version:        2.0");
                                        string directoryver = ("FileDirectory version:    1.0");
                                        string mathver = ("Math version:             1.0");
                                        string runprogver = ("Run version:              2.0");
                                        string mdirversion = ("MakeDir(mdir) version:    1.0");
                                        string movdirversion = ("MoveDir(movdir) version:  1.0");
                                        string ddirversion = ("DeleteDir(ddir) version:  1.0");
                                        string logver = ("Log version:              1.2");
                                        SETUPFILE.WriteLine(datecreated);
                                        SETUPFILE.WriteLine(dosversion);
                                        SETUPFILE.WriteLine(kernelversion);
                                        SETUPFILE.WriteLine(bootloaderver);
                                        SETUPFILE.WriteLine(doswriterver);
                                        SETUPFILE.WriteLine(helpver);
                                        SETUPFILE.WriteLine(directoryver);
                                        SETUPFILE.WriteLine(mathver);
                                        SETUPFILE.WriteLine(runprogver);
                                        SETUPFILE.WriteLine(mdirversion);
                                        SETUPFILE.WriteLine(movdirversion);
                                        SETUPFILE.WriteLine(ddirversion);
                                        SETUPFILE.WriteLine(logver);
                                        //write the version(s)
                                        Console.WriteLine("The CDOS icon, and name is copyrighted   ");
                                        Console.WriteLine("by Taranoshi Nikari/Mata Nui (c2013)");//hey, copyrighted by me.
                                        Console.WriteLine("=========================================");
                                        Console.WriteLine(dosversion);
                                        Console.WriteLine(datecreated);
                                        Console.WriteLine(kernelversion);
                                        Console.WriteLine(bootloaderver);
                                        Console.WriteLine("");
                                        Console.WriteLine("Program Versions:----------------------->");
                                        Console.WriteLine("");
                                        Console.WriteLine(helpver);
                                        Console.WriteLine(doswriterver);
                                        Console.WriteLine(directoryver);
                                        Console.WriteLine(mathver);
                                        Console.WriteLine(runprogver);
                                        Console.WriteLine(mdirversion);
                                        Console.WriteLine(movdirversion);
                                        Console.WriteLine(ddirversion);
                                        Console.WriteLine(logver);
                                        Console.WriteLine("=========================================");
                                        Console.WriteLine("");
                                        Console.WriteLine("=========================================");
                                        Console.WriteLine("Copyright c2013 Taranoshi Nikari/Mata Nui");
                                        Console.WriteLine("");
                                        Console.WriteLine("This program is free software: you can   ");
                                        Console.WriteLine("redistribute it and/or modify it under   ");
                                        Console.WriteLine("the terms of the GNU General Public      ");
                                        Console.WriteLine("License as published by the Free Software");
                                        Console.WriteLine("Foundation, either version 2 of the      ");
                                        Console.WriteLine("License, or (at your option) any later   ");
                                        Console.WriteLine("version.");
                                        Console.WriteLine("");
                                        Console.WriteLine("This program is distributed in the hope  ");
                                        Console.WriteLine("that it will be useful, but WITHOUT ANY  ");
                                        Console.WriteLine("WARRANTY; without even the implied       ");
                                        Console.WriteLine("warranty of MERCHANTABILITY or FITNESS   ");
                                        Console.WriteLine("FOR A PARTICULAR PURPOSE. See the GNU    ");
                                        Console.WriteLine("General Public License for more details. ");
                                        Console.WriteLine("");
                                        Console.WriteLine("You should have recieved a copy of the   ");
                                        Console.WriteLine("GNU General Public License along with    ");
                                        Console.WriteLine("this program. If not, see                ");
                                        Console.WriteLine("<http://www.gnu.org/licenses/>           ");//the license website
                                        Console.WriteLine("=========================================");
                                        goto begin;
                                    }
                                    else
                                        if (command == RESTART)//restart the virtual dos
                                        {
                                            Console.WriteLine("Restarting.....");
                                            Console.WriteLine("Ending Processes.....");
                                            Console.WriteLine("Rebooting");
                                            SETUPFILE.WriteLine(DateTime.Today.ToString() + "Restarting C-DOS");
                                            Console.Beep();
                                            goto boot;
                                        }
                                        else
                                            if (command == SHUTOFF)//turn off the program
                                            {
                                                Console.WriteLine("Thankyou for using CDOS :-)");
                                                Console.WriteLine("Goodbye.");
                                                Console.WriteLine("Shutting down.....");
                                                Console.WriteLine("Ending Processes.....");
                                                Console.WriteLine("Closing the command interface.....");
                                                SETUPFILE.WriteLine(DateTime.Today.ToString() + "Shutting down C-DOS");
                                                SETUPFILE.Close();
                                                Console.Beep();
                                            }
                                            else
                                                if (command == CLEAR)//clear the screen(main loop)
                                                {
                                                    SETUPFILE.WriteLine(DateTime.Today.ToString() + "Cleared the screen");
                                                    Console.WriteLine("Clearing Screen");
                                                    Console.Clear();
                                                    goto begin;
                                                }
                                                else
                                                    if (command == RUN)//run an external file
                                                    {
                                                        try
                                                        {
                                                            Console.Write("Enter Program Name(must be in current working directory): ");
                                                            string runfile = Console.ReadLine();
                                                            string directory = Directory.GetCurrentDirectory();
                                                            Process.Start(runfile, directory);
                                                            SETUPFILE.WriteLine(DateTime.Today.ToString() + "Externel executionable executed");
                                                            goto begin;
                                                        }
                                                        catch
                                                        {
                                                            Console.WriteLine("Error: no such file or directory found!!");
                                                            SETUPFILE.WriteLine(DateTime.Today.ToString() + "Error in run command: no such file or directory found!!");
                                                        }
                                                    }
                                                    else
                                                        if (command == MATH)//math program
                                                        {
                                                            SETUPFILE.WriteLine(DateTime.Today.ToString() + "Math program executed");
                                                            Console.WriteLine("Welcome to the 'Math' program");
                                                        MathLoop:
                                                            Console.Write("\\Math:");
                                                            string mathcommand = Console.ReadLine();
                                                            SETUPFILE.WriteLine(DateTime.Today.ToString() + "Math Command:" + mathcommand);
                                                            if (mathcommand == "help")//help me i dont know what to do!!
                                                            {
                                                                Console.WriteLine("============Math Help Menu============");
                                                                Console.WriteLine("| help    = Math help menu           |");
                                                                Console.WriteLine("| add     = add two numbers together |");
                                                                Console.WriteLine("| subtrak = subtract two numbers     |");
                                                                Console.WriteLine("| multi   = multiply two numbers     |");
                                                                Console.WriteLine("| divide  = divide two numbers       |");
                                                                Console.WriteLine("| exit    = exit the Math program    |");
                                                                Console.WriteLine("| clr     = clear the screen         |");
                                                                Console.WriteLine("| NOTE: not able to clear screen     |");
                                                                Console.WriteLine("| while in a'mode'(add, subtrak, etc)|");
                                                                Console.WriteLine("======================================");
                                                                goto MathLoop;
                                                            }
                                                            else
                                                                if (mathcommand == "add")//lets add numbers
                                                                {
                                                                addloop:
                                                                    try
                                                                    {
                                                                        Console.Write("Please enter the first number: ");//you mean i have to enter a number!?
                                                                        string addnumst = Console.ReadLine();
                                                                        int addnum1 = Convert.ToInt32(addnumst);
                                                                        Console.Write("Please enter the second number: ");//i have to enter TWO numbers!?
                                                                        string addnum2st = Console.ReadLine();
                                                                        int addnum2 = Convert.ToInt32(addnum2st);
                                                                        int answer = addnum1 + addnum2;
                                                                        Console.WriteLine("The answer is: " + answer);
                                                                    }
                                                                    catch
                                                                    {
                                                                        Console.WriteLine("ERROR: unable to process :-(");//oh man!!
                                                                        SETUPFILE.WriteLine(DateTime.Today.ToString() + "Unable to add those two numbers!!");
                                                                        goto addloop;
                                                                    }
                                                                    Console.Write("Do you wish to continue? (yes/no): ");//sure i would!
                                                                    string mathexit = Console.ReadLine();
                                                                    if (mathexit == "yes")
                                                                    {
                                                                        goto addloop;
                                                                    }
                                                                    else
                                                                    {
                                                                        goto MathLoop;
                                                                    }
                                                                }
                                                                else
                                                                    if (mathcommand == "subtrak")//lets take stuff away!
                                                                    {
                                                                    subtrakloop:
                                                                        try
                                                                        {
                                                                            Console.Write("Please enter first number: ");
                                                                            string subtraknumst = Console.ReadLine();
                                                                            int subtraknum1 = Convert.ToInt32(subtraknumst);
                                                                            Console.Write("Please enter the second number: ");
                                                                            string subtraknumst2 = Console.ReadLine();
                                                                            int subtraknum2 = Convert.ToInt32(subtraknumst2);
                                                                            int answer = subtraknum1 - subtraknum2;
                                                                            Console.WriteLine("The answer is: " + answer);
                                                                        }
                                                                        catch
                                                                        {
                                                                            Console.WriteLine("ERROR: unable to process. :-(");//come on, man!!
                                                                            SETUPFILE.WriteLine(DateTime.Today.ToString() + "Unable to subtrak those two numbers!!");
                                                                            goto subtrakloop;
                                                                        }
                                                                        Console.Write("Do you wish to continue? (yes/no): ");//sure i'd like to
                                                                        string mathexit = Console.ReadLine();
                                                                        if (mathexit == "yes")
                                                                        {
                                                                            goto subtrakloop;
                                                                        }
                                                                        else
                                                                        {
                                                                            goto MathLoop;
                                                                        }
                                                                    }
                                                                    else
                                                                        if (mathcommand == "multi")//lets multiply numbers!!
                                                                        {
                                                                        multiloop:
                                                                            try
                                                                            {
                                                                                Console.Write("PLease enter first number: ");
                                                                                string multinum1st = Console.ReadLine();
                                                                                int multinum1 = Convert.ToInt32(multinum1st);
                                                                                Console.Write("Please enter second number: ");
                                                                                string multinum2st = Console.ReadLine();
                                                                                int multinum2 = Convert.ToInt32(multinum2st);
                                                                                int answer = multinum1 * multinum2;
                                                                                Console.WriteLine("The answer is: " + answer);
                                                                            }
                                                                            catch
                                                                            {
                                                                                Console.WriteLine("ERROR: unable to process. :-(");//oh man!!
                                                                                SETUPFILE.WriteLine(DateTime.Today.ToString() + "Unable to multiply those two numbers!!");
                                                                                goto multiloop;
                                                                            }
                                                                            Console.Write("Do you wish to continue? (yes/no): ");
                                                                            string mathexit = Console.ReadLine();
                                                                            if (mathexit == "yes")
                                                                            {
                                                                                goto multiloop;
                                                                            }
                                                                            else
                                                                            {
                                                                                goto MathLoop;
                                                                            }
                                                                        }
                                                                        else
                                                                            if (mathcommand == "divide")//yay my favorite(yeah right)!!
                                                                            {
                                                                            divideloop:
                                                                                try
                                                                                {
                                                                                    Console.Write("PLease enter first number: ");
                                                                                    string multinum1st = Console.ReadLine();
                                                                                    int multinum1 = Convert.ToInt32(multinum1st);
                                                                                    Console.Write("Please enter second number: ");
                                                                                    string multinum2st = Console.ReadLine();
                                                                                    int multinum2 = Convert.ToInt32(multinum2st);
                                                                                    int answer = multinum1 / multinum2;
                                                                                    Console.WriteLine("The answer is: " + answer);
                                                                                }
                                                                                catch
                                                                                {
                                                                                    Console.WriteLine("ERROR: unable to process(or attemp to divide by zero). :-(");//what zero?
                                                                                    SETUPFILE.WriteLine(DateTime.Today.ToString() + "Unable to divide those two numbers(or attempt to divide by zero)!!");
                                                                                    goto divideloop;
                                                                                }
                                                                                Console.Write("Do you wish to continue? (yes/no): ");//YES!!!
                                                                                string mathexit = Console.ReadLine();
                                                                                if (mathexit == "yes")
                                                                                {
                                                                                    goto divideloop;
                                                                                }
                                                                                else
                                                                                {
                                                                                    goto MathLoop;
                                                                                }
                                                                            }
                                                                            else
                                                                                if (mathcommand == "exit")
                                                                                {
                                                                                    goto begin;
                                                                                }
                                                                                else
                                                                                    if (mathcommand == "clr")
                                                                                    {
                                                                                        Console.Clear();
                                                                                        goto MathLoop;
                                                                                    }
                                                        }
                                                        else
                                                            if (command == chkdsk)
                                                            {
                                                                SETUPFILE.WriteLine(DateTime.Today.ToString() + "Executing the chkdsk program");
                                                                Console.WriteLine("Starting chkdsk.....");//lets check my disk
                                                                Process.Start("chkdsk.exe", "C:/Windows/System32");
                                                                goto begin;
                                                            }
                                                            else
                                                                if (command == def)
                                                                {
                                                                    try
                                                                    {
                                                                        SETUPFILE.WriteLine(DateTime.Today.ToString() + "Executing the defrag program");
                                                                        Console.WriteLine("Starting defrag.....");//lets defrag!!
                                                                        Process.Start("Defrag.exe", "C:/Windows/System32");
                                                                        goto begin;
                                                                    }
                                                                    catch
                                                                    {
                                                                        SETUPFILE.WriteLine(DateTime.Today.ToString() + "Unable to execute the defrag program, insufficient privilages!!");
                                                                        Console.WriteLine("Unable to execute, not sufficient privilages!!!");//ahhhhhhhhhh!!!!!!!!
                                                                        goto begin;
                                                                    }
                                                                }
                                                                else
                                                                    if (command == cmd)
                                                                    {
                                                                        SETUPFILE.WriteLine(DateTime.Today.ToString() + "switching from C-DOS to Windows Command Console");
                                                                        Console.WriteLine("Switching to the Windows console.....");//ok....
                                                                        Process.Start("cmd.exe", "C:/Windows/System32");
                                                                        goto begin;
                                                                    }
                                                                    else
                                                                        if (command == "tree")
                                                                        {
                                                                            SETUPFILE.WriteLine(DateTime.Today.ToString() + "Reading the drive using the tree program");
                                                                            Console.WriteLine("Reading Disk.....");//ooooooo.....aaaaahhhhhh!!!!!!!
                                                                            Process.Start("tree.com", "C:/Windows/System32");
                                                                            goto begin;
                                                                        }
                                                                        else
                                                                            if (command == "wexplore")
                                                                            {
                                                                                SETUPFILE.WriteLine(DateTime.Today.ToString() + "Executing Explorer.exe");
                                                                                Console.WriteLine("Starting Windows File Explorer.....");//sweet!
                                                                                Process.Start("explorer.exe", "C:/Windows");
                                                                                goto begin;
                                                                            }
                                                                            else
                                                                                if (command == "calc")
                                                                                {
                                                                                    SETUPFILE.WriteLine(DateTime.Today.ToString() + "Executing calc.exe");
                                                                                    Console.WriteLine("Starting the Windows Calculator program.....");//ok.....
                                                                                    Process.Start("calc.exe", "C;/Windows/System32");
                                                                                    goto begin;
                                                                                }
                                                                                else
                                                                                    if (command == "music")
                                                                                    {
                                                                                        SETUPFILE.WriteLine(DateTime.Today.ToString() + "Executing Windows Media Player");
                                                                                        Console.WriteLine("Starting the Windows Media Player.....");//lets pick up the beat!
                                                                                        try
                                                                                        {
                                                                                            Process.Start("wmplayer.exe", "C:/Program Files(x86)/Windows Media Player");
                                                                                            goto begin;
                                                                                        }
                                                                                        catch
                                                                                        {
                                                                                            Process.Start("wmplayer.exe", "C:/Program Files/Windows Media Player");
                                                                                            goto begin;
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                        if (command == "exit")
                                                                                        {
                                                                                            Console.WriteLine("Thankyou for using CDOS :-)");//goodbye
                                                                                            Console.WriteLine("Goodbye.");
                                                                                            Console.WriteLine("Shutting down.....");
                                                                                            Console.WriteLine("Ending Processes.....");
                                                                                            Console.WriteLine("Closing the command interface.....");
                                                                                            SETUPFILE.WriteLine(DateTime.Today.ToString() + "Shutting down C-DOS");
                                                                                            SETUPFILE.Close();
                                                                                            Console.Beep();
                                                                                        }
                                                                                        else
                                                                                            if (command == "mdir")
                                                                                            {
                                                                                                Console.Write("Enter a directory to create a folder in:");
                                                                                                string mkdir = Console.ReadLine();
                                                                                                Console.Write("Enter a folder name:");
                                                                                                string mkdirname = Console.ReadLine();
                                                                                                SETUPFILE.WriteLine(DateTime.Today.ToString() + "Attempting to create a folder:" + mkdir + mkdirname);
                                                                                                try
                                                                                                {
                                                                                                    Directory.CreateDirectory(mkdir + mkdirname);
                                                                                                }
                                                                                                catch
                                                                                                {
                                                                                                    SETUPFILE.WriteLine(DateTime.Today.ToString() + "Unable to create specified directory");
                                                                                                    Console.WriteLine("Error: unable to create a directory!!!!");
                                                                                                    goto begin;
                                                                                                }
                                                                                                Console.WriteLine("Directory creation successful@" + mkdir + mkdirname);
                                                                                                SETUPFILE.WriteLine(DateTime.Today.ToString() + "Directory:" + mkdir + mkdirname + "created successively");
                                                                                                goto begin;
                                                                                            }
                                                                                            else
                                                                                                if (command == "ddir")
                                                                                                {
                                                                                                    Console.Write("Enter a directory to delete:");
                                                                                                    string ddirname = Console.ReadLine();
                                                                                                    SETUPFILE.WriteLine(DateTime.Today.ToString() + "Attempting to delete:" + ddirname);
                                                                                                    try
                                                                                                    {
                                                                                                        Directory.Delete(ddirname, true);
                                                                                                    }
                                                                                                    catch
                                                                                                    {
                                                                                                        SETUPFILE.WriteLine(DateTime.Today.ToString() + "Unable to delete the specified directory");
                                                                                                        Console.WriteLine("Error: unable to delete the specified directory!!");
                                                                                                    }
                                                                                                    SETUPFILE.WriteLine(DateTime.Today.ToString() + "Directory termination successful");
                                                                                                    Console.WriteLine("Deletion successful!!");
                                                                                                    goto begin;
                                                                                                }
                                                                                                else
                                                                                                    if (command == "movdir")
                                                                                                    {
                                                                                                        Console.Write("Enter directory to move:");
                                                                                                        string firdir = Console.ReadLine();
                                                                                                        Console.Write("Enter directory to move the first directory to:");
                                                                                                        string secdir = Console.ReadLine();
                                                                                                        SETUPFILE.WriteLine(DateTime.Today.ToString() + "Attempting to move:" + firdir + "to:" + secdir);
                                                                                                        try
                                                                                                        {
                                                                                                            Directory.Move(firdir, secdir);
                                                                                                        }
                                                                                                        catch
                                                                                                        {
                                                                                                            SETUPFILE.WriteLine(DateTime.Today.ToString() + "Unable to move the specified directory");
                                                                                                            Console.WriteLine("Error: unable to move to specified directory!!");
                                                                                                            goto begin;
                                                                                                        }
                                                                                                        SETUPFILE.WriteLine(DateTime.Today.ToString() + "Directory movement successful");
                                                                                                        Console.WriteLine("Directory movement completed!");
                                                                                                        goto begin;
                                                                                                    }
                                                                                                    else
                                                                                                        if (command == "login")
                                                                                                        {
                                                                                                            SETUPFILE.WriteLine(DateTime.Today.ToString() + "Relogging in with a different Username");
                                                                                                            goto Login;
                                                                                                        }
                                                                                                        else
                                                                                                            if (command != HELP)
                                                                                                            {
                                                                                                                COMMANDERROR(c);
                                                                                                            }
                                                                                                            else
                                                                                                                if (command != DIRECTORY)
                                                                                                                {
                                                                                                                }
                                                                                                                else
                                                                                                                    if (command != EDIT)
                                                                                                                    {
                                                                                                                    }
                                                                                                                    else
                                                                                                                        if (command != VER)
                                                                                                                        {
                                                                                                                        }
                                                                                                                        else
                                                                                                                            if (command != RESTART)
                                                                                                                            {
                                                                                                                            }
                                                                                                                            else
                                                                                                                                if (command != SHUTOFF)
                                                                                                                                {
                                                                                                                                }
                                                                                                                                else
                                                                                                                                    if (command != CLEAR)
                                                                                                                                    {
                                                                                                                                    }
                                                                                                                                    else
                                                                                                                                        if (command != RUN)
                                                                                                                                        {
                                                                                                                                        }
                }
                catch
                {
                    SETUPFILE.WriteLine(DateTime.Today.ToString() + "No such command found in the C-DOS Command Manager");
                    Console.WriteLine("ERROR: No such command found!!!! :-(");//awww SNAP!!!!
                    goto begin;
                }
            }
            else
            {
                StreamWriter SETUPFILE = new StreamWriter(File.Open(GETCURRENT + "\\log.txt", FileMode.Create));
                goto Cont;
            }
        }

        private static void COMMANDERROR(object c)
        {
            throw new NotImplementedException();
        }
    }
}
